package com.financing.wap.web.controller.adminapi;

import com.financing.wap.common.Pager;
import com.financing.wap.common.ResultMap;
import com.financing.wap.dto.DstPosterDTO;
import com.financing.wap.dto.DstUserComplainDTO;
import com.financing.wap.service.IDstUserComplainService;
import com.financing.wap.util.StringUtil;
import com.financing.wap.vo.admin.AdminUserComplainVO;
import com.financing.wap.web.controller.BaseController;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.List;

/***
 * 用户投诉
 *
 */
@Controller("adminDstUserComplainController")
@RequestMapping("/adminapi/dstUserComplain")
public class DstUserComplainController extends BaseController  { 

	private Logger logger = Logger.getLogger(getClass());
	
	@Autowired
	private IDstUserComplainService dstUserComplainService;
	/***
	 * 后台投诉列表
	 * @param request
	 * @return
	 */
	@RequestMapping("/dstUserComplainList.shtml")
	@ResponseBody
	public ResultMap add(HttpServletRequest request, AdminUserComplainVO userComplainVO,Pager pager){
		ResultMap result = new ResultMap();
		
		try{
			logger.info("query dstUserComplainList  begin .......");

			userComplainVO.setBegin(pager.getStartIndex());
			userComplainVO.setPageSize(pager.getPageSize());
			int count = dstUserComplainService.adminQueryListCount(userComplainVO);

			pager.setTotalCount(count);

			List<AdminUserComplainVO> dstPosterList = null;

			if(count > 0){
				dstPosterList = dstUserComplainService.adminQueryList(userComplainVO);
			}else{
				dstPosterList = Collections.emptyList();
			}

			result.setAttribute("pager", pager);
			result.setAttribute("list", dstPosterList);
			result.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
			result.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
			result.setStatus(ResultMap.STATUS.SUCCESS);
			
			logger.info("query dstUserComplainList list end .......");
		}catch(Exception e){
			log.error("query dstUserComplainList error!",e);
			result.setStatus(ResultMap.STATUS.ERROR);
			result.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
		}
		
		return result;
	}
	
	
}
